//
//  ViewController.m
//  RuntimeDemo
//
//  Created by zheng on 16/3/12.
//  Copyright © 2016年 zheng. All rights reserved.
//

#import "ViewController.h"
#import <objc/runtime.h>
#import "PLTUserModel.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    // Get properties of a class through runtime
    unsigned int count = 0;
    objc_property_t *properties = class_copyPropertyList([UILabel class], &count);
    for (int i = 0; i < count; i++) {
        objc_property_t property = properties[i];
        const void *propertyName = property_getName(property);
//        NSLog(@"the property name: %@", [NSString stringWithUTF8String:propertyName]);
    }
    
    NSDictionary *userDict = @{@"name": @"Joseph", @"genders": @"male", @"age": @(26), @"address": @"chaoyang beijing", @"hobbies": @[@"coding", @"reading", @"car"]};
    PLTUserModel *userModel = [[PLTUserModel alloc] initWithDictionary:userDict];
    NSLog(@"the model: %@", userModel.name);
    
    NSLog(@"the dict: %@", [userModel toDictionary]);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
